package com.leetcode.lccup;

/**
 * @author `RKC`
 * @date 2022/4/16 15:02
 */
public class LCCUP1宝石补给 {

    public int giveGem(int[] gem, int[][] operations) {
        for (int[] operation : operations) {
            int u = operation[0], v = operation[1];
            int t = gem[u] / 2;
            gem[v] += t;
            gem[u] -= t;
        }
        int maxv = 0, minv = 0x3f3f3f3f;
        for (int j : gem) {
            maxv = Math.max(maxv, j);
            minv = Math.min(minv, j);
        }
        return maxv - minv;
    }
}
